<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>21.正则的匹配重复的第n个子项</title>
        <script>
            /**
             * \1 匹配的第一个重复的子项
             * \2 匹配的第二个重复的子项
             * \n 匹配的第n个重复的子项
             */
            var str = 'abca';
            /**
             * abca true
             */
            var re = /(a)(b)(c)\1/;
            /**
             * abcb false
             */
            // var re = /(a)(b)(c)\2/;
            alert(re.test(str));

            /**
             * var re = /\w\w/; // 匹配的是比如c9
             * var re = /(\w)\1/; // 匹配的是比如cc 99
             */
        </script>
    </head>
    <body>

    </body>
</html>
